package com.ruoyi.st.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.st.domain.StTicketPrice;
import com.ruoyi.st.service.IStTicketPriceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 票面价格Controller
 * 
 * @author ruoyi
 * @date 2024-11-07
 */
@RestController
@RequestMapping("/st/ticketPrice")
public class StTicketPriceController extends BaseController
{
    @Autowired
    private IStTicketPriceService stTicketPriceService;

    /**
     * 查询票面价格列表
     */
    @PreAuthorize("@ss.hasPermi('st:ticketPrice:list')")
    @GetMapping("/list")
    public TableDataInfo list(StTicketPrice stTicketPrice)
    {
        startPage();
        List<StTicketPrice> list = stTicketPriceService.selectStTicketPriceList(stTicketPrice);
        return getDataTable(list);
    }

    /**
     * 导出票面价格列表
     */
    @PreAuthorize("@ss.hasPermi('st:ticketPrice:export')")
    @Log(title = "票面价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StTicketPrice stTicketPrice)
    {
        List<StTicketPrice> list = stTicketPriceService.selectStTicketPriceList(stTicketPrice);
        ExcelUtil<StTicketPrice> util = new ExcelUtil<StTicketPrice>(StTicketPrice.class);
        util.exportExcel(response, list, "票面价格数据");
    }

    /**
     * 获取票面价格详细信息
     */
    @PreAuthorize("@ss.hasPermi('st:ticketPrice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stTicketPriceService.selectStTicketPriceById(id));
    }

    /**
     * 新增票面价格
     */
    @PreAuthorize("@ss.hasPermi('st:ticketPrice:add')")
    @Log(title = "票面价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StTicketPrice stTicketPrice)
    {
        return toAjax(stTicketPriceService.insertStTicketPrice(stTicketPrice));
    }

    /**
     * 修改票面价格
     */
    @PreAuthorize("@ss.hasPermi('st:ticketPrice:edit')")
    @Log(title = "票面价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StTicketPrice stTicketPrice)
    {
        return toAjax(stTicketPriceService.updateStTicketPrice(stTicketPrice));
    }

    /**
     * 删除票面价格
     */
    @PreAuthorize("@ss.hasPermi('st:ticketPrice:remove')")
    @Log(title = "票面价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stTicketPriceService.deleteStTicketPriceByIds(ids));
    }
}
